import request from '@/config/axios'

interface parkDataType {
  name: string
  number: string
  intro: string
  relevance: string
  objectId?: string
}
interface WhereType {
  name: { $regex: string; $options: 'i' }
}
export const Overview = (page: number = 1, size: number = 10, condition?: { name: string }) => {
  const skip = (page - 1) * size
  const where: WhereType = {} as WhereType
  // 携带设备名称
  if (condition && condition.name) {
    where.name = { $regex: condition.name, $options: 'i' }
  }

  const query = JSON.stringify(where)
  return request.get({
    url: `/1.1/classes/Job?where=${query}&limit=${size}&count=${1}&skip=${skip}`
  })
}
// 新增
export const parkAdd = (data) => {
  return request.post({ url: '/1.1/classes/Job', data })
}

// 新增编辑
export const parkPut = (id: string, data: Omit<parkDataType, 'objectId'>) => {
  // 发起put请求
  return request.put({ url: `/1.1/classes/Job/${id}`, data })
}
// 删除
export const parkDel = (id: string) => {
  return request.delete({ url: `/1.1/classes/Job/${id}` })
}
